# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=cdrkit
pkgver=1.1.11
pkgrel=6
pkgdesc="Suite of programs for CD/DVD recording, ISO image creation, and audio CD extraction"
url="http://cdrkit.org/"
arch="all"
options="!check"  # No test suite.
license="GPL-2.0-only"
depends="file bzip2"
makedepends="cmake libcap-dev bzip2-dev samurai zlib-dev"
subpackages="$pkgname-doc"
source="https://dev.alpinelinux.org/archive/cdrkit/cdrkit-$pkgver.tar.gz
	gcc10.patch
	implicit.patch
	werrorformat.patch
	"

prepare() {
	# disable rcmd, it is security risk and not implemented in musl
	sed -i include/xconfig.h.in -e "s/#define HAVE_RCMD 1/#undef HAVE_RCMD/g"
	default_prepare
}

build() {
	export CFLAGS="$CFLAGS -D__THROW=''"

	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	cd "$pkgdir/usr/bin"
	ln -s wodim cdrecord
	ln -s readom readcd
	ln -s genisoimage mkisofs
	ln -s genisoimage mkhybrid
	ln -s icedax cdda2wav

	cd "$pkgdir/usr/share/man/man1"
	ln -s wodim.1 cdrecord.1
	ln -s readom.1 readcd.1
	ln -s genisoimage.1 mkisofs.1
	ln -s genisoimage.1 mkhybrid.1
	ln -s icedax.1 cdda2wav.1
}

sha512sums="
e5afcd2cb68d39aeff680a0d5b0a7877f94cf6de111b3cb7388261c665fbd3209ce98a20a01911875af7d6b832a156801b1fa46a4481f7c8ba60b22eac0a5b05  cdrkit-1.1.11.tar.gz
bf008b30136eb4997014eb30594c66594d1cd0073942b9ca129058fba02d310aa8e364341cda5bced11941b9f26c73a10523a3e19505e6496e8cf818e857c791  gcc10.patch
2eb344990092337025180b7255faf1f27243e3102852030d6b8f8e404850e957afefa73ebca8398dd474e71adba3a91751a95eb3e4b84afe031db7a857784a84  implicit.patch
52a18be2fcbfa666adc9084a1410a075c5983c4f6aa72d5536192109ef586b212ba635f34b3780f0afe354eb62ac29edc04afc69bcb77e7c4251cc5209ba5db8  werrorformat.patch
"
